/**
 * Created by DukeCrushIt on 2015/8/31.
 */
class MailInfo{
    public awarded:boolean;
    public content:string;
    public hasAward:boolean;
    public hasRevenge:boolean;
    public id:number;
    public read:boolean;
    public senderId:number;
    public senderName:string;
    public receiverId:number;
    public receiverName:string;
    public revenged:boolean;
    public sendTime:number;
    public pillageId:number;
    public title:string;
    public type:number;

    public catHair:number=0;
    public dogHair:number=0;
    public diamond:number=0;
    public props:any[];
    public constructor(data:any=null){
        this.props = [];
        if(data != null)
            this.initFromData(data);
    }
    public initFromData(data:any){
        this.senderName = data.senderName;
        this.id = data.id;
        this.content = data.content;
        this.awarded = data.awarded;
        this.read = data.read;
        this.hasAward = data.hasAward;
        this.title = data.title;
        this.type = data.type;

        this.hasRevenge = data.hasRevenge;
        this.senderId = data.senderId;
        this.receiverId = data.receiverId;
        this.receiverName = data.receiverName;
        this.revenged = data.revenged;
        this.sendTime = data.sendTime;
        this.pillageId = data.config.pillageId;

        if( this.hasAward){
            var award = data.config.award;
            if( award != undefined){
                this.catHair = award.catHair;
                this.dogHair = award.dogHair;
                this.diamond = award.diamond;
                for(var key in award.props){
                    this.props.push([key,award.props[key]])
                }
            }
        }
    }
}